﻿using System;
using System.Collections;
using System.Collections.Generic;
using MrPP.Common;
using UnityEngine;

namespace MrPP.SerriedCabinet
{
    public class CheckCtrl : CheckPost
    {
        [SerializeField]
        private CheckPost _post;
     //   [SerializeField]
        CheckModel _model;
        public void Start()
        {
         //   _model.onState += doState;
            QRCodeManager.Instance.onRecevie += doQRCode;
        }

        private void doQRCode(string code)
        {
            doCheck(code);
        }

        private void doState(State arg1, State arg2)
        {
            if (arg2 == State.Running)
            {
                QRCodeManager.Instance.open();
            }
            else {
                QRCodeManager.Instance.close();
            }
        }

        private void OnDestroy()
        {
            if (QRCodeManager.IsInitialized) {

                QRCodeManager.Instance.onRecevie -= doQRCode;
            }
          //  if (_model) {
          //      _model.onState -= doState;
          //  }
        }
        public override void doCheck(string key)
        {
            _post.doCheck(key);
        }

        public override void doLast()
        {
            _post.doLast();
        }

        public override void doNext()
        {
            _post.doNext();
        }

        public override void doPlay()
        {
           // Debug.LogError("do play");
            _post.doPlay();
        }

        public override void doStop()
        {
           // Debug.LogError("do stop");
            _post.doStop();
        }

        public override void doTab(int idx)
        {
            _post.doTab(idx);
        }
        

    }
}